import request from '../utils/request';

export function auth(params){
    return request.get('/user/auth',{
        params : params
    })
}

// 用户登录
export function login(data){
    return request.post('/user/login',data)
}

// 获取登录的用户信息
export function getUserInfo(){
    return request.get('/user/userInfo',{})
}

// 退出登录
export function logout(){
    return request.post('/user/logout',{})
}

// 获取用户列表
export function GetUserList(){
    return request.get('/user/userList',{})
}

// 停用用户
export function userStop(id){
    return request.put('/user/stop/'+ id )
}

// 启用用户
export function userStart(id){
    return request.put('/user/start/'+ id )
}

// 更新用户
export function updateUser(data){
    return request.post('/user/updateUser',{
        'address' : data.address,
        'created' : data.created,
        'description' : data.description,
        'email' : data.email,
        'file' : data.file,
        'id' : data.id,
        'password' : data.password,
        'phone' : data.phone,
        'roleId' : data.roleId,
        'roleNames' : data.roleNames,
        'sex' : data.sex,
        'state' : data.state,
        'updated' : data.updated,
        'username' : data.username,
    })
}


// 获取权限列表
export function GetPermisSionList(){
    return request.get('/user/permissionList',{})
}

// 获取角色列表
export function GetRoleList(){
    return request.get('/user/roleList',{})
}

//添加用户
export function addUser(data){
    return request.post('/user/addUser',{
        username: data.username,
        password: data.password,
        email: data.email,
        phone: data.phone,
        sex: data.sex,
        state: data.state,
        description: data.description,
        roleId: data.roleId
    })
}

// 获取角色列表
export function delUser(params){
    return request.delete('/user/delUser/'+params,{})
}
